package com.ajun.springbootenable;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;

import java.util.Map;

/*
* Import4种用法：
*   1.导入Bean
*   2.导入配置类
*   3.导入ImportSelector的实现类
*   4.导入ImportBeanDefinitionRegistrar实现类
* */

@Import(SecurityProperties.User.class)
@SpringBootApplication
public class SpringbootEnableApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SpringbootEnableApplication.class, args);

//        //获取Bean
//        Object user = context.getBean("user");
//        System.out.println(user);

        SecurityProperties.User user = context.getBean(SecurityProperties.User.class);
        System.out.println(user);

        Map<String, SecurityProperties.User> map = context.getBeansOfType(SecurityProperties.User.class);
        System.out.println(map);
    }

}
